var status = 0;

function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (status == 0 && mode == 0) {
        cm.dispose();
        return;
    }
    if (mode == 1) {
        status++;
    } else {
        status--;
    }
    if (status == 0) {
        var selStr = "只要给我30个#v4001868#模糊的刻印灵魂石和\r\n1个#v4001869#扭曲的刻印灵魂石，\r\n我就给你1个#v4310199#烙印币，怎么样？\r\n#L0##v4310199#烙印币";
        cm.sendSimple(selStr);
    } else if (status == 1) {
        switch (selection) {
            case 0:
                if (cm.haveItem(4001868, 30) && cm.haveItem(4001869, 1)) {
                    cm.gainItem(4001868, -30); //模糊的刻印灵魂石
                    cm.gainItem(4001869, -1); //扭曲的刻印灵魂石
                    cm.gainItem(4310199, 1); //烙印币
                    cm.sendOk("兑换成功！可以找我旁边补给兵购买道具！");
                } else {
                    cm.sendOk("失败：\r\n\r\n#r1). #v4001868#模糊的刻印灵魂石数量不足.\r\n2).#v4001869#扭曲的刻印灵魂石数量不足\r\n\r\n3). 其他栏不足请及时清理.");
                }
                break;
        }
        cm.dispose();
    }
}